package com.hundsun.cprs.yyt.service.goods.service.impl;

import com.hundsun.cprs.yyt.common.base.BaseService;
import com.hundsun.cprs.yyt.service.goods.dao.GoodsWithAreaDao;
import com.hundsun.cprs.yyt.service.goods.domain.GoodsWithArea;
import com.hundsun.cprs.yyt.service.goods.service.GoodsWithAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class GoodsWithAreaServiceImpl extends BaseService implements GoodsWithAreaService {

    @Autowired
    private GoodsWithAreaDao goodsWithAreaDao;

    @Override
    public void insert(GoodsWithArea record) {
        goodsWithAreaDao.insert(record);
    }

    @Override
    @CacheEvict(value="YYT:AREA:GOODS",key="#goodsWithArea.areaCode.toUpperCase() + ':' + new String(#goodsWithArea.goodsId)")
    @Transactional
    public void update(GoodsWithArea goodsWithArea) {
        goodsWithAreaDao.updateByGoodsIdAndAreaCode(goodsWithArea);
    }
}
